package o;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.huawei.appmarket.R;
import com.huawei.appmarket.service.apppermission.bean.GroupPermissionInfo;
import com.huawei.appmarket.service.apppermission.bean.PermissionInfo;
import com.huawei.appmarket.service.apppermission.bean.SingleAppPermissionInfo;
import java.util.ArrayList;

public class dlj implements ExpandableListAdapter {
    private String ˋ = "BatchAppPermissionAdapter";
    private ArrayList<SingleAppPermissionInfo> ˎ;
    private Context ˏ;
    private int ॱ;

    static class a {
        private TextView ˎ;
        private TextView ˏ;
        private LinearLayout ॱ;

        private a() {
        }
    }

    static class d {
        private TextView ˊ;
        private ImageView ˋ;

        private d() {
        }
    }

    public dlj(Context context, @NonNull ArrayList<SingleAppPermissionInfo> arrayList) {
        this.ˏ = context;
        this.ˎ = arrayList;
        this.ॱ = context.getResources().getDimensionPixelSize(R.dimen.padding_m);
    }

    public void registerDataSetObserver(DataSetObserver dataSetObserver) {
    }

    public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
    }

    public int getGroupCount() {
        return this.ˎ.size();
    }

    public Object getGroup(int i) {
        return ((SingleAppPermissionInfo) this.ˎ.get(i)).ˋ();
    }

    public long getGroupId(int i) {
        return (long) i;
    }

    public View getGroupView(int i, boolean z, View view, ViewGroup viewGroup) {
        String str = (String) getGroup(i);
        if (view == null || !(view.getTag() instanceof d)) {
            view = LayoutInflater.from(this.ˏ).inflate(R.layout.oobe_group_batch_permission_item_view, null);
            azb.ˏ(view, R.id.permission_item_content);
            d dVar = new d();
            dVar.ˊ = (TextView) view.findViewById(R.id.batch_per_item);
            dVar.ˊ.setText(str);
            dVar.ˋ = (ImageView) view.findViewById(R.id.arrow);
            view.setTag(dVar);
        }
        d dVar2 = (d) view.getTag();
        dVar2.ˊ.setText(str);
        if (z) {
            dVar2.ˋ.setImageResource(R.drawable.ic_public_arrow_up_900);
        } else {
            dVar2.ˋ.setImageResource(R.drawable.ic_public_arrow_down_900);
        }
        return view;
    }

    public int ˋ(int i, int i2) {
        int i3 = -1;
        for (GroupPermissionInfo groupPermissionInfo : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i3++;
            if (i2 == i3) {
                return 0;
            }
            int size = groupPermissionInfo.ˏ().size() + i3;
            if (i2 <= size) {
                return 1;
            }
            i3 = size;
        }
        return 1;
    }

    public int getChildrenCount(int i) {
        int i2 = 0;
        for (GroupPermissionInfo ˏ : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i2 = ˏ.ˏ().size() + (i2 + 1);
        }
        return i2;
    }

    public Object getChild(int i, int i2) {
        int i3 = -1;
        for (GroupPermissionInfo groupPermissionInfo : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i3++;
            if (i2 == i3) {
                return groupPermissionInfo.ˎ();
            }
            int size = groupPermissionInfo.ˏ().size();
            i3 += size;
            if (i2 <= i3) {
                return ((PermissionInfo) groupPermissionInfo.ˏ().get((size - (i3 - i2)) - 1)).ॱ();
            }
        }
        return "";
    }

    public long getChildId(int i, int i2) {
        return (long) i2;
    }

    public View getChildView(int i, int i2, boolean z, View view, ViewGroup viewGroup) {
        View ˎ = ˎ(view);
        String str = (String) getChild(i, i2);
        a aVar = (a) ˎ.getTag();
        if (ˋ(i, i2) == 0) {
            ˏ(str, aVar);
        } else {
            ॱ(str, aVar);
        }
        return ˎ;
    }

    private void ॱ(String str, a aVar) {
        aVar.ˎ.setText(str);
        aVar.ॱ.setVisibility(0);
        aVar.ˏ.setVisibility(8);
    }

    private void ˏ(String str, a aVar) {
        aVar.ˏ.setText(str);
        aVar.ॱ.setVisibility(8);
        aVar.ˏ.setVisibility(0);
        aVar.ˏ.setPadding(0, 0, 0, 0);
    }

    private View ˎ(View view) {
        if (view != null && (view.getTag() instanceof a)) {
            return view;
        }
        view = LayoutInflater.from(this.ˏ).inflate(R.layout.oobe_batch_child_permission_item_view, null);
        azb.ˏ(view);
        a aVar = new a();
        aVar.ˏ = (TextView) view.findViewById(R.id.batch_per_item_groupdesc);
        aVar.ˎ = (TextView) view.findViewById(R.id.batch_per_item);
        aVar.ॱ = (LinearLayout) view.findViewById(R.id.batch_per_item_layout);
        view.setTag(aVar);
        return view;
    }

    public boolean hasStableIds() {
        return false;
    }

    public boolean isChildSelectable(int i, int i2) {
        return false;
    }

    public boolean areAllItemsEnabled() {
        return false;
    }

    public boolean isEmpty() {
        return false;
    }

    public void onGroupExpanded(int i) {
    }

    public void onGroupCollapsed(int i) {
    }

    public long getCombinedChildId(long j, long j2) {
        return 0;
    }

    public long getCombinedGroupId(long j) {
        return 0;
    }
}
